package com.mzpai.product.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mzpai.product.constant.ProductConstants;
import com.mzpai.product.mapper.StoreProductAttrMapper;
import com.mzpai.product.model.StoreProductAttr;
import com.mzpai.product.service.StoreProductAttrService;
import com.mzpai.service.impl.BaseServiceImpl;
/**
 *
 * <b>商品品牌 | Service</b><br>
 *
 * guguanfei 2021-03-16 18:48:49
 * 
 *  @version 1.0.0
 *
 */
@Service
public class StoreProductAttrServiceImpl extends BaseServiceImpl<StoreProductAttr> implements StoreProductAttrService {

	Logger logger = LoggerFactory.getLogger(StoreProductAttrServiceImpl.class);

	@Autowired 
	private StoreProductAttrMapper mapper;

	@Override
	public void deleteByProductIdAndType(Integer productId,Integer type) {
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("productId", productId);
		map.put("type", type);
		mapper.deleteByProductIdAndType(map);
		
	}

	/**
	 * 根据商品id,查询
	 * @param id
	 * @return
	 */
	@Override
	public List<StoreProductAttr> getListByProductId(Integer productId) {
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("productId", productId);
		map.put("type", ProductConstants.ACTIVE_TYPE_0);
		return mapper.getList(map);
	}

	@Override
	public void syncProduct(int productId) {
		mapper.syncProduct(productId);
	}
}